#pragma once
#pragma warning(disable:4996)       // disable checked iterator errors http://msdn.microsoft.com/en-us/library/aa985965(VS.80).aspx 

//
// Copyright (C) 2011 Steve Channell steve.channell@cepheis.com
//
// This file is part of Cephei.QL, an open-source library wrapper 
// arround QuantLib http://quantlib.org/
//
// Cephei.QL is open source software: you can redistribute it and/or modify it
// under the terms of the license.  You should have received a
// copy of the license along with this program; if not, please email
// <support@cepheis.com>. The license is also available online at
// <http://cepheis.com/license.htm>.
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE.  See the license for more details.
//
// Version 2.101

#include <Macros.h>
#include <CoVector.h>
#include <CoMatrix.h>
#include <CoCube.h>
#include <ValueHelpers.h>
#include <Settings.h>

#include <gen/QL/Termstructures/VolatilityTermStructure.h>
#pragma unmanaged 
#include <ql\termstructures\volatility\swaption\spreadedswaptionvol.hpp>
#include <boost/smart_ptr/detail/spinlock.hpp>
#pragma managed 

using namespace System;
using namespace QuantLib;
using namespace Cephei;

using namespace Cephei::QL::Times;
using namespace Cephei::QL;
using namespace Cephei::QL::Termstructures;
#define HANDLE
#undef ABSTRACT
#undef STRUCT
namespace Cephei { namespace QL { namespace Termstructures { namespace Volatility { namespace Swaption {
	//////////////////////////////////////////////////////////////////////////////////////////////
	// implementation of ISpreadedSwaptionVolatility
	public ref class CSpreadedSwaptionVolatility : 
            public CVolatilityTermStructure,
            public Cephei::QL::Termstructures::Volatility::Swaption::ISpreadedSwaptionVolatility
	{
	protected: 
		boost::shared_ptr<QuantLib::SpreadedSwaptionVolatility>* _ppSpreadedSwaptionVolatility;
#ifdef HANDLE
		QuantLib::Handle<QuantLib::SpreadedSwaptionVolatility>* _phSpreadedSwaptionVolatility;
#endif
		Object^ _SpreadedSwaptionVolatilityOwner;     // reference to object that manages the storage for this object
	internal:
        CSpreadedSwaptionVolatility (boost::shared_ptr<QuantLib::SpreadedSwaptionVolatility>& childNative, Object^ owner);
        CSpreadedSwaptionVolatility (QuantLib::SpreadedSwaptionVolatility& childNative, Object^ owner);
        CSpreadedSwaptionVolatility (CSpreadedSwaptionVolatility^ copy);
        CSpreadedSwaptionVolatility (System::Type^ t);
#ifdef STRUCT
        CSpreadedSwaptionVolatility (QuantLib::SpreadedSwaptionVolatility childNative);
#endif       
#ifdef HANDLE
		CSpreadedSwaptionVolatility (QuantLib::Handle<QuantLib::SpreadedSwaptionVolatility>& childNative, Object^ owner);
		CSpreadedSwaptionVolatility (QuantLib::Handle<QuantLib::SpreadedSwaptionVolatility> childNative);
#endif
		virtual ~CSpreadedSwaptionVolatility ();
		!CSpreadedSwaptionVolatility ();

	internal:
		QuantLib::SpreadedSwaptionVolatility& GetReference ();
		boost::shared_ptr<QuantLib::SpreadedSwaptionVolatility>& GetShared ();
		QuantLib::SpreadedSwaptionVolatility* GetPointer ();
        void SetSpreadedSwaptionVolatility (boost::shared_ptr<QuantLib::SpreadedSwaptionVolatility> native)
        {
            if (_ppSpreadedSwaptionVolatility != NULL)
                delete _ppSpreadedSwaptionVolatility;
            _ppSpreadedSwaptionVolatility = new boost::shared_ptr<QuantLib::SpreadedSwaptionVolatility> (native);
            SetVolatilityTermStructure (boost::dynamic_pointer_cast<QuantLib::VolatilityTermStructure> (*_ppSpreadedSwaptionVolatility));
        }
#ifdef HANDLE
		QuantLib::Handle<QuantLib::SpreadedSwaptionVolatility>& GetHandle ();
#endif
		virtual bool HasNative () override;
    public:
        property Cephei::QL::Times::ICalendar^ Calendar 
        {
		    virtual Cephei::QL::Times::ICalendar^ get () ;
        }
        property Cephei::QL::Times::IDayCounter^ DayCounter 
        {
		    virtual Cephei::QL::Times::IDayCounter^ get () ;
        }
        property DateTime MaxDate 
        {
		    virtual DateTime get () ;
        }
        property Double MaxStrike 
        {
		    virtual Double get () ;
        }
        property Cephei::QL::Times::IPeriod^ MaxSwapTenor 
        {
		    virtual Cephei::QL::Times::IPeriod^ get () ;
        }
        property Double MaxTime 
        {
		    virtual Double get () ;
        }
        property Double MinStrike 
        {
		    virtual Double get () ;
        }
        property DateTime ReferenceDate 
        {
		    virtual DateTime get () ;
        }
        property UInt32 SettlementDays 
        {
		    virtual UInt32 get () ;
        }
        property Cephei::QL::Times::ICalendar^ M1969_Calendar 
        {
            virtual Cephei::QL::Times::ICalendar^ get () = Cephei::QL::ITermStructure::Calendar::get
            {
                return ((Cephei::QL::Termstructures::Volatility::Swaption::ISpreadedSwaptionVolatility^)this)->Calendar;
            }
        }
        property Cephei::QL::Times::IDayCounter^ M1969_DayCounter 
        {
            virtual Cephei::QL::Times::IDayCounter^ get () = Cephei::QL::ITermStructure::DayCounter::get
            {
                return ((Cephei::QL::Termstructures::Volatility::Swaption::ISpreadedSwaptionVolatility^)this)->DayCounter;
            }
        }
        property DateTime M1969_MaxDate 
        {
            virtual DateTime get () = Cephei::QL::ITermStructure::MaxDate::get
            {
                return ((Cephei::QL::Termstructures::Volatility::Swaption::ISpreadedSwaptionVolatility^)this)->MaxDate;
            }
        }
        property Double M1969_MaxTime 
        {
            virtual Double get () = Cephei::QL::ITermStructure::MaxTime::get
            {
                return ((Cephei::QL::Termstructures::Volatility::Swaption::ISpreadedSwaptionVolatility^)this)->MaxTime;
            }
        }
        property DateTime M1969_ReferenceDate 
        {
            virtual DateTime get () = Cephei::QL::ITermStructure::ReferenceDate::get
            {
                return ((Cephei::QL::Termstructures::Volatility::Swaption::ISpreadedSwaptionVolatility^)this)->ReferenceDate;
            }
        }
        property UInt32 M1969_SettlementDays 
        {
            virtual UInt32 get () = Cephei::QL::ITermStructure::SettlementDays::get
            {
                return ((Cephei::QL::Termstructures::Volatility::Swaption::ISpreadedSwaptionVolatility^)this)->SettlementDays;
            }
        }
    };
	//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	// Factory class
	public ref class CSpreadedSwaptionVolatility_Factory : public System::MarshalByRefObject,  public ISpreadedSwaptionVolatility_Factory
	{
	public:
    };
   
/*Cephei*/ } /*QL*/ } /*Termstructures*/ } /*Volatility*/ } /*Swaption */}
